<template>
  <main>
    <!-- 头部-->
    <header>
      <h3 @click="fanClick()">&lt;</h3>
      <div class="h_bottom">
        <div class="h_input"><input type="text" placeholder="搜索" /></div>
        <span
          @click="navClick(index)"
          :class="{ active: ssIndex == index }"
          v-for="(item, index) in nav"
          :key="index"
          >{{ item.name }}</span
        >
      </div>
    </header>

    <!-- 导航 -->
    <ul>
      <li v-for="(item, index) in shopinfo.taglist " :key="index">
        <span
          @click="listClick(index)"
          :class="{ active: ssIndexnav == index }"
          >{{ item.name }}</span
        >
      </li>
    </ul>

    <!-- 商品列表 -->
    <div class="content">
      <h3>热销</h3>
      <div class="foodlist" v-for="(item, index) in  shopinfo.taglist && shopinfo.taglist[ssIndexnav].goodlist" :key="index">
        <div class="left"><img :src="item.picture" alt="" /></div>
        <div class="right">
          <h4>{{ item.name }}</h4>
          <p class="desc">{{ item.month_saled}}</p>
          <div class="bottom">
            <span>￥{{ item.min_price}}</span>
            <button>+</button>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部 -->
    <footer>
      <div class="bm_left">
        <div class="icon"><span class="iconfont">&#xe609;</span></div>
        <div class="bm_content">
          <span>￥{{}}</span>
          <p>另需配送费38元</p>
        </div>
      </div>
      <button>去结算</button>
    </footer>
  </main>
</template>

<script >
import {shop_shopinfo} from "../api/api"
export default {
  data() {
    return {
      ssIndex: 0,
      ssIndexnav: 0,
      nav: [{ name: "点餐" }, { name: "评价" }, { name: "商家" }],
      shopinfo:{},
    };
  },
  mounted(){
    shop_shopinfo({id: this.$route.params.id}).then((res)=>{
      if(res.data.code ==200){
        console.log(res.data.shopinfo);
        this.shopinfo = res.data.shopinfo
      }else{
        alert(res.data.msg)
        this.$router.go(-1)
      }
    })
  },
  methods: {
    navClick(index) {
      this.ssIndex = index;
    },
    listClick(index) {
      this.ssIndexnav = index;
    },
    fanClick(){
      this.$router.go(-1)
    }
  },
};
</script>

<style scoped>
/* 头部样式 */
header {
  font-size: 18px;
  height: 14vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  align-content: center;
  border-bottom: 1px solid rgb(229, 229, 229);
  /* background-color: rgb(199, 199, 199); */
}
header h3 {
  color: rgb(0, 183, 255);
  box-sizing: border-box;
  padding: 1vh 2vh;
  font-size: 25px;
}
.h_bottom {
  display: flex;
  height: 5vh;
  line-height: 6vh;
}
.h_bottom .h_input {
  box-sizing: border-box;
  margin-right: 5.3333vw;
  margin-left: 2.6667vw;
}
header .h_bottom .h_input input {
  width: 20vw;
  height: 4vh;
  line-height: 4vh;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  border-radius: 25px;
  border: transparent;
  border: 1px solid rgb(203, 203, 203);
  outline: none;
  box-sizing: border-box;
}
header .h_bottom span {
  margin-right: 4vw;
  margin-left: 1vw;
}
header .h_bottom span.active {
  box-sizing: border-box;
  color: rgb(21, 178, 240);
  display: inline-block;
  border-bottom: 2px solid rgb(21, 178, 240);
}

/* 导航样式 */
ul {
  float: left;
  list-style: none;
  box-sizing: border-box;
  width: 14vw;
}
ul li {
  box-sizing: border-box;
  margin-left: 0.6667vw;
  color: rgb(101, 101, 101);
  font-size: 14px;
  /* background-color: gray; */
  width: 28vw;
  height: 8vh;
  line-height: 8vh;
  text-align: center;
}
ul li span {
  box-sizing: border-box;
  display: inline-block;
  width: 28vw;
  height: 16px;
  line-height: 16px;
}
ul li span.active {
  color: red;
  font-weight: 700;
  border-left: 1px solid red;
}

/* 商品列表 */
.content {
  float: right;
  width: 70vw;
  overflow: auto;
  height: 77vh;
  box-sizing: border-box;
}
.content h3 {
  padding: 0.5vh 0;
}
.content .foodlist {
  margin: 4vw auto 0.5vw;
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
  width: 70vw;
  height: 11.5vh;
  /* background-color: red; */
}
.content .foodlist .left {
  width: 25vw;
  height: 11.5vh;
  /* margin-right: 5px; */
}
img {
  width: 100%;
  height: 100%;
}
.content .foodlist .right {
  position: relative;
  width: 42vw;
}
.content .foodlist .right h4 {
  margin-bottom: 0.05rem;
}
.content .foodlist .right .desc {
  font-size: 14px;
  color: rgb(133, 133, 133);
}
.content .foodlist .right .bottom {
  position: absolute;
  bottom: 2.25px;
  display: flex;
  justify-content: space-between;
  width: 90%;
}
.content .foodlist .right .bottom span {
  color: red;
  font-size: 18px;
}
.content .foodlist .right .bottom button {
  width: 7vw;
  height: 7vw;
  text-align: center;
  border-radius: 50%;
  color: white;
  border: transparent;
  background-color: rgb(30, 169, 224);
}

/* 底部 */
footer {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  align-items: center;
  height: 9vh;
  bottom: 0;
  width: 100vw;
  background-color: gray;
}

footer .bm_left {
  display: flex;
  align-items: center;
}

footer .iconfont {
  font-size: 60px;
  color: blue;
  margin-right: 10px;
}

footer .bm_content {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-around;
}

footer button {
  height: 6vh;
  width: 35vw;
  margin-right: 10vw;
  border-radius: 5px;
  font-size: 20px;
  color: white;
  outline: none;
  border: transparent;
  background-color: rgb(19, 203, 5);
}
</style>